/*******************************************************************/
/* @ All Rights Reserved Copyright (C) 2014 broada,Co.,Ltd.        */
/*                                                                 */
/*  NAME      = t__sip_destroy_packet.c                           */
/*  NOTE      =                                                    */
/*  DATE      = 2016/02/16 by songbb                               */
/*******************************************************************/

#include <CUnit/Basic.h>
#include <stdlib.h>

#include "frcomm.h"
#include "frmem.h"

#include "../../../src/module/sip/config.h"
#include "../test_sip_comm.h"
#include <sip/sip_core.h>
#include <sip/sip_header.h>
#include <sip/sip_comm.h>
#include <sip/sip_packet.h>
#include <frct_comm.h>

void __sip_destroy_packet(L7_sip_packet **pp_st_sip_packet);

static int __suite_init(void)
{
    return 0;
}

static int __suite_cleanup(void)
{
    return 0;
}

static void __case1(void)
{
    L7_sip_packet *p_st_sip_packet = NULL;
    p_st_sip_packet = (L7_sip_packet *) frmalloc(sizeof(L7_sip_packet));
    CU_ASSERT_PTR_NOT_NULL(p_st_sip_packet);
    memset(p_st_sip_packet, 0x00, sizeof(L7_sip_packet));

    __sip_destroy_packet(&p_st_sip_packet);
    CU_ASSERT_PTR_NULL(p_st_sip_packet);
}

static void __case2(void)
{
    L7_sip_packet *p_st_sip_packet = NULL;
    __sip_destroy_packet(&p_st_sip_packet);
    CU_ASSERT_PTR_NULL(p_st_sip_packet);
}

int add_suite__sip_destroy_packet(void)
{
    CU_pSuite pSuite = NULL;

    if ((pSuite = CU_add_suite(MODULE_NAME" __sip_destroy_packet()", __suite_init, __suite_cleanup)) == NULL)
        return FR_FAIL;

    if (CU_add_test(pSuite, "case1", __case1) == NULL ||
        CU_add_test(pSuite, "case2", __case2) == NULL)
        return FR_FAIL;

    return FR_SUCC;
}
